﻿using System;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Threading.Tasks;
using WeatherNet.yahoo;
using System.Collections;
using System.Diagnostics;

namespace WeatherNet.Test
{
    [TestClass]
    public class WeatherNetTest
    {
        [TestMethod]
        public async Task GetMultiCityWeather()
        {
            var client = new YahooWeatherClient();
            var weather = await client.GetWeatherValues("bellary", "bellevue", "paris");

            Assert.IsNotNull(weather);
            Assert.AreEqual(3, weather.Count(), "unexpected result count");

            weather.ToList().ForEach(w =>
                {
                    Assert.IsNotNull(w.City);
                    Assert.IsNotNull(w.Country);
                    Assert.IsNotNull(w.Region);

                    Assert.IsNotNull(w.Forecast);
                    Assert.IsNotNull(w.Date);
                    Assert.IsNotNull(w.Summary);
                    w.Forecast.ToList().ForEach(f =>
                        {
                            Assert.IsNotNull(f.Date);
                            Assert.IsNotNull(f.Day);
                            Assert.IsNotNull(f.Summary);
                            Assert.IsTrue(f.High > f.Low);

                        });

                    Debug.WriteLine(w);
                });

        }
    }
}
